#ifndef __RAM_H__
#define __RAM_H__

#define NO_WORKFRAME 1
#if !NO_WORKFRAME
#define BATCH_DRAW 1
#else
#define BATCH_DRAW 0
#endif

#define PAL_DRAW 1 //must NO_WORKFRAME == 1

struct BYTE_ARR_ {
	int startpos;
	int maxsize;
	unsigned char *memptr;
};
typedef struct BYTE_ARR_ BYTE_ARR;


extern void BYTE_ARR_clone_from2_work(BYTE_ARR *target, BYTE_ARR *arr, int addr); //ignore
extern void BYTE_ARR_memsetword_work(BYTE_ARR *arr, int addr, unsigned char val, int size);
extern void BYTE_ARR_SetWord_work(BYTE_ARR *arr, int addr, unsigned short val);
extern void BYTE_ARR_plus_work(BYTE_ARR *arr, int inc); //ignore
extern unsigned short BYTE_ARR_GetWord_work(BYTE_ARR *arr, int addr);
extern BYTE_ARR *BYTE_ARR_calloc_work(int size1, int size2); //ignore

extern BYTE_ARR *BYTE_ARR_calloc(int size1, int size2);
extern BYTE_ARR *BYTE_ARR_calloc_from(unsigned char *mem);
extern BYTE_ARR *BYTE_ARR_clone(BYTE_ARR *arr);
extern BYTE_ARR *BYTE_ARR_clone_from(BYTE_ARR *arr, int addr);
extern void BYTE_ARR_clone_from2(BYTE_ARR *target, BYTE_ARR *arr, int addr);
extern int BYTE_ARR_equals(BYTE_ARR *arr, BYTE_ARR *arr2);
extern void BYTE_ARR_plus(BYTE_ARR *arr, int inc);
extern int BYTE_ARR_minus(BYTE_ARR *arr, BYTE_ARR *arr2);

extern unsigned char BYTE_ARR_Get(BYTE_ARR *arr, int addr);
extern unsigned long BYTE_ARR_GetDWord(BYTE_ARR *arr, int addr);
extern void BYTE_ARR_Set(BYTE_ARR *arr, int addr, unsigned char val);
extern void BYTE_ARR_SetWord(BYTE_ARR *arr, int addr, unsigned short val);
extern unsigned short BYTE_ARR_GetWord(BYTE_ARR *arr, int addr);
extern void BYTE_ARR_memset(BYTE_ARR *arr, int addr, unsigned char val, int size);
extern void BYTE_ARR_memcpy(unsigned char *mem, BYTE_ARR *arr, int addr, int size);

extern void Mem_Init(void);
extern void Mem_Read(unsigned char* pBuffer, int ReadAddr, int NumByteToRead);
extern void Mem_Write(unsigned char* pBuffer, int WriteAddr, int NumByteToWrite);

#endif
